#### Start of system configuration section. ####

srcdir =	@srcdir@

ifeq ($(srcdir),.)
srcdir = ../..
endif

VPATH :=	$(srcdir)


# Common prefix for machine-independent installed files.
prefix =	@prefix@

# Common prefix for machine-dependent installed files.
exec_prefix =	@exec_prefix@

bindir =	$(exec_prefix)/bin
libdir =	$(exec_prefix)/Sys/libs

INSTALL =	@INSTALL@
INSTALL_DATA =	@INSTALL_DATA@

CC =		@CC@

CFLAGS =	@CFLAGS@
LDFLAGS =	@LDFLAGS@

RANLIB =	@RANLIB@
AR =		ar

#### End system configuration section ####

ifdef CATENATE
DEBUG_FLAG =	-g
else
DEBUG_FLAG =	
endif

# I *love* GNU make!
define catenate
/bin/echo -n creating $@...
/bin/echo "$(^:%=#include \"%\"\n)" >$@
/bin/echo done
endef

FLAVOR_CFLAGS =	-m$(CPU) -m$(FPU)
ALL_CFLAGS =	$(CFLAGS) $(FLAVOR_CFLAGS) $(OTHER_CFLAGS) $(DEBUG_FLAG) $(INCS)

INCS =		-I$(srcdir) -I$(srcdir)/../library -I$(srcdir)/../include
LIB =		libgeneral.a

.c.o:
		$(CC) $(ALL_CFLAGS) -c $< -o $@

SRC =		_setjmp.c alarm.c clock.c crypt.c ctype_.c difftime.c \
		errlst.c fnmatch.c getlogin.c getmntinfo.c getwd.c \
		insque.c isctype.c isinf.c isnan.c mktemp.c pause.c \
		psignal.c raise.c random.c remove.c remque.c setjmp.c \
		setjmperr.c siginterrupt.c siglist.c signal.c sigsetjmp.c \
		sigsetops.c sleep.c termios.c time.c times.c ualarm.c \
		uname.c unvis.c usleep.c vis.c wait.c wait3.c waitpid.c

OBJ =		$(SRC:.c=.o)

A4_SRC =	glob.c

A4_OBJ =	$(A4_SRC:.c=.o)

ifdef CATENATE
ALL =		all.o a4.o arith.o
else
ALL =		$(OBJ) $(A4_OBJ) arith.o
endif

$(LIB):		$(ALL)
		rm -f $@
		$(AR) rv $@ $(ALL)
		$(RANLIB) $@

all.c:		$(SRC)
		@$(catenate)

a4.c:		$(A4_SRC)
		@$(catenate)

$(A4_OBJ) a4.o:	%.o: %.c
		$(CC) $(ALL_CFLAGS) -ffixed-a4 -c $< -o $@

arith.o:	arith.c
		$(CC) $(ALL_CFLAGS) -DALL -c $< -o $@

clean:
		rm -rf 680?0

clobber:	clean
		rm -f Makefile
